<script type="text/javascript">
	function del() {
		ui_confirm('确定要删除吗?',function(){
			sendAjax("{:U('mark','action=del')}", 'id=' + $("#id").val(), function(data) {
				if (data.status) {
					ui_alert(data.info,function(){
						window.open($("#next_link").attr("href"), '_self');
					});						
				}
			});
		});
	}

	function mark_spam() {
		sendAjax("{:U('mark','action=spam')}", 'mail_id=' + $("#id").val(), function(data) {
			if (data.status) {
				ui_info(data.info);
			}
		});
	}

	function del_forever() {
		sendAjax("{:U('mark','action=del_forever')}", 'mail_id=' + $("#id").val(), function(data) {
			if (data.status) {
				ui_info(data.info);
			}
		});
	}

	function forword() {
		if ($("input[name='mail_id']:checkbox:checked").length == 1) {
			window.open(fix_url("{:U('reply')}?id=" + $("input[name='mail_id']:checkbox:checked:first").val()) + "&type=forward", "_self");
		} else {
			ui_error("请选择一封要转发的邮件");
			return false;
		};
	}

	function mark(val) {
		if (val == "readed") {
			sendAjax("{:U('mark','action=readed')}", 'main_id=' + $("#id").val());
		} else {
			sendAjax("{:U('mark','action=unread')}", 'main_id=' + $("#id").val());
		}
	}

	function move_to(val) {
		sendAjax("{:U('mark','action=move_folder')}", 'val=' + val + '&mail_id=' + $("#id").val(), function(data) {
			ui_info(data.info);
		});
	}

	function reply(type) {
		if (type == "reply") {
			setTimeout(function() {
				window.location.href = fix_url("{:U('reply','id='.$vo['id'])}?type=" + type);
			}, 300);
		} else {
			window.location.href = fix_url("{:U('reply','id='.$vo['id'])}?type=" + type);
		}
	}

	$(document).ready(function() {
		$("#move_to li").click(function() {
			move_to($(this).attr("id"));
		});
		show_content();
	});
</script>